fn main() {
    let mut names = vec!["Bob", "Frank", "Ferris"];
    // 借用 ,但是不会改变原来的值，所以后面还可以使用
    // 借用的意思是引用
    for name in names.iter() {
        match name {
            // 这里的name是引用，所以需要取字串的引用
            &"Ferris" => println!("There is a rustacean among us!"),
            // TODO ^ Try deleting the & and matching just "Ferris"
            _ => println!("Hello {}", name),
        }
    }
    
    println!("names: {:?}", names);
    // Once the collection has been consumed it is no longer available for reuse as it has been 'moved' within the loop.
    // move 的意思是值
    // 这里的names已经被移动到for循环中，所以不能再使用，需要clone一份
    for name in names.clone().into_iter() {
        match name {
            // 所以这里的name已经是值了，所以不需要再借用了
            "Ferris" => println!("There is a rustacean among us!"),
            _ => println!("Hello {}", name),
        }
    }
    
    println!("2 names: {:?}", names);
    // FIXME ^ Comment out this line

    // 可变引用
    for name in names.iter_mut() {
        *name = match name {
            // 这里的name是可变引用，所以可以直接修改值
            &mut "Ferris" => "There is a rustacean among us!",
            _ => "Hello",
        }
    }

    println!("names: {:?}", names);
}